package com.c6906.vdam.das.service.impl;

import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.c6906.vdam.das.dao.VehiclesParkingDataDAO;
import com.c6906.vdam.das.model.entity.VehiclesParkingData;
import com.c6906.vdam.das.service.VehiclesParkingDataService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class VehiclesParkingDataServiceImpl extends ServiceImpl<VehiclesParkingDataDAO, VehiclesParkingData> implements VehiclesParkingDataService {
    @Resource
    private IService<VehiclesParkingData> vehicleTripDataService;
    @Override
    public VehiclesParkingData getLatestTripData(String vehiclesCode) {
        return vehicleTripDataService.lambdaQuery()
                .eq(VehiclesParkingData::getVehiclesCode, vehiclesCode) // 添加条件
                .orderByDesc(VehiclesParkingData::getCreateTime) // 按 create_time 降序
                .last("LIMIT 1") // 限制返回 1 条记录
                .one(); // 获取单个结果
    }
}
